package com.gy.smart.tool.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gy.smart.R;
import com.gy.smart.tool.bean.ToolBean;
import com.gy.smart.util.ListViewItemListener;

import java.util.List;

/**
 * Created by 高岳 on 2017/1/5.
 * Describe:工具子类adapter
 */
public class ToolChildAdapter extends BaseAdapter {

    private Context context;
    private List<ToolBean.ToolChildBean> datas;
    private ListViewItemListener listener;

    public ToolChildAdapter(Context context,List<ToolBean.ToolChildBean> datas){
        this.context = context;
        this.datas = datas;
    }

    public void setListener(ListViewItemListener listener){
        this.listener = listener;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.adapter_tool_child,null);
        TextView tvName = (TextView) convertView.findViewById(R.id.adapter_tool_child_tv_name);
        tvName.setText(datas.get(position).title);
        tvName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.doPassActionListener(null,0,position,"");
            }
        });
        return convertView;
    }
}
